home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / cat.3 / ftw.3 < prev    next >
Text File  |  1995-07-27  |  4KB  |  133 lines

  1.  
  2.  
  3.  
  4.      FFFFTTTTWWWW((((3333))))                    UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV                    FFFFTTTTWWWW((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.           ftw - walk a file tree
  10.  
  11.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.           ####iiiinnnncccclllluuuuddddeeee <<<<ffffttttwwww....hhhh>>>>
  13.  
  14.           iiiinnnntttt
  15.           ffffttttwwww((((ddddiiiirrrreeeeccccttttoooorrrryyyy,,,, ffffuuuunnnnccccppppttttrrrr,,,, ddddeeeepppptttthhhh))))
  16.                cccchhhhaaaarrrr ****ddddiiiirrrreeeeccccttttoooorrrryyyy;;;;
  17.                iiiinnnntttt ((((****ffffuuuunnnnccccppppttttrrrr))))(((())));;;;
  18.                iiiinnnntttt ddddeeeepppptttthhhh;;;;
  19.  
  20.           ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ssssttttaaaatttt....hhhh>>>>
  21.  
  22.           iiiinnnntttt
  23.           ffffuuuunnnnccccppppttttrrrr((((iiiitttteeeemmmm,,,, ssssbbbb,,,, ffffllllaaaagggg))))
  24.                cccchhhhaaaarrrr ****iiiitttteeeemmmm;;;;
  25.                ssssttttrrrruuuucccctttt ssssttttaaaatttt ****ssssbbbb;;;;
  26.                iiiinnnntttt ffffllllaaaagggg;;;;
  27.  
  28.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  29.           _F_t_w walks through the directory tree starting from the
  30.           indicated _p_a_t_h.  For every entry it finds in the tree, it
  31.           calls the user-supplied _f_u_n_c_p_t_r with the calling sequence
  32.           given in the synopsis above.  The first argument is the full
  33.           pathname of the entry (rooted from the _d_i_r_e_c_t_o_r_y parameter
  34.           given to _f_t_w); the second argument is a pointer to the
  35.           _s_t_a_t(2) structure for the entry; and the third argument is
  36.           one of the #define's in the header file.  This value will be
  37.           one of the following:
  38.                FTW_F    Item is a normal file
  39.                FTW_D    Item is a directory
  40.                FTW_NS   The stat failed on the item
  41.                FTW_DNR  Item is a directory which can't be read
  42.           Note, however, that FTW_F is a misnomer; anything other than
  43.           directories are (e.g., symbolic links) get the FTW_F tag.
  44.  
  45.           _F_t_w recursively calls itself when it encounters a directory.
  46.           To avoid using up all a program's file descriptors, the
  47.           _d_e_p_t_h argument specifies the number of simultaneous open
  48.           directories to maintain.  When the depth is exceeded, the
  49.           routine will become noticeably slower because directories
  50.           are closed in ``most-recently-used'' order.
  51.  
  52.           To stop the tree walk, the user-supplied function should
  53.           return a non-zero value; this value will become the return
  54.           value of _f_t_w.  Otherwise, _f_t_w will continue until it has
  55.           scanned the entire tree, in which case it will return zero,
  56.           or until it hits an error such as a _m_a_l_l_o_c(3) failure, in
  57.           which case it will return -1.
  58.  
  59.           Because _f_t_w uses dynamic data structures, the only safe way
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 7/27/95)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      FFFFTTTTWWWW((((3333))))                    UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV                    FFFFTTTTWWWW((((3333))))
  71.  
  72.  
  73.  
  74.           to exit out of a tree walk is to return a non-zero value.
  75.           To handle interrupts, for example, mark that the interrupt
  76.           occured and return a non-zero value- don't use _l_o_n_g_j_m_p (_3)
  77.           unless the program is going to terminate.
  78.  
  79.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  80.           stat(2)
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 7/27/95)
  130.  
  131.  
  132.  
  133.